

<template>
  <!-- 
     读卡 读不到只能新建 所以输入没有必要
     读卡  读到了  就只能修改了
     所以输入是没有必要的
-->
  <div class="addUserInfo">
    
    <ViewTitle text="基础信息" />
    <div class="box1">
      <div>
        <span>患者姓名:</span>
        <el-input
          size="mini"
          
          v-model="patient.name"
          placeholder="请输入病人姓名"
        >
        </el-input>
      </div>
        <div>
        <span>身份证号:</span>
        <el-input
          size="mini"
        maxlength="18"
         @input="inputCard"
          v-model="patient.id_card"
          placeholder="请输入卡号"
        ></el-input>
      </div>
      <div>
        <span>性别:</span>
        <el-select
          size="mini"
          
          v-model="patient.gender"
          placeholder="请选择性别"
        >
          <el-option
            v-for="(item, index) in $baseBai['gender']"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </div>
      <div>
        <span>年龄:</span>
        <el-input
          
          size="mini"
          type="number"
          v-model="patient.age"
          placeholder="请输入年龄"
        ></el-input>
      </div>
    

      <div>
        <span>生日:</span>
       
        <el-date-picker
          
          v-model="patient.birthday"
          size="mini"
          type="date"
          
       
          value-format="yyyy-MM-dd"
          placeholder="选择日期"
        >
        </el-date-picker> 

        
      </div>

      <div>
        <span>患者电话:</span>
        <el-input
          
          size="mini"
          type="tel"
          v-model="patient.phone"
          placeholder="请输入内容"
           maxlength="11"
        ></el-input>
      </div>
      <div>
        <span>家庭住址:</span>
        <el-input
          
          size="mini"
          v-model="patient.address"
          placeholder="请输入家庭住址"
        ></el-input>
      </div>
    </div>

  <ViewTitle text="陪护人信息" />

    <div class="box1">
      <div>
        <span>陪护人姓名:</span>
        <el-input
          size="mini"
          v-model="patient.fast_name"
          placeholder="请输入陪同人员姓名"
        >
        </el-input>
      </div>
      
      <div>
        <span>陪护人电话:</span>
        <el-input
          size="mini"
          type="tel"
          v-model="patient.fast_phone"
          placeholder="请输入陪护人电话"
          maxlength="11"
        ></el-input>
      </div>
      
    


   
    </div>



    <div class="buts">
          <el-button  class="butB_Add"  @click="save()">保存</el-button>
    </div>
  </div>
</template>
<script>
import ViewTitle from "@/forComponents/viewTitle/index.vue";
export default {
  props: ['patient','thatF'],
  data() {
    return {
      // params: {
      //    name: "",
      //   id_card: "",
      //   gender: "",
      //   age: "",
      //   birthday: "",
      //   phone: "",
      //   address: "",
      // },

   
    };
  },
  mounted(){
    
  },
  watch:{
      showAddUserInfo:(newVal, oldVal)=>{
       
      }
  },
  methods: {
   inputCard(e){
    //  console.log("e",e)

    
    let str= this.$utilsB.GetAge(e)
      if(str){
         this.patient.age=str.age;
          this.patient.gender=str.gender;
         this.patient.birthday=str.birthday;
      }
   console.log("utilsB",str)
   },
    save(){

        
                // for(let key in this.params){
                //       if(!this.params[key])
                //       return  this.$message.error('请填写资料完整后再进行提交');
                // }


        if(!this.patient.name){
           return  this.$message.error('请输入患者姓名');
        }
          if(!this.patient.fast_name){
           return  this.$message.error('请输入陪护人姓名');
        }

  if(!this.patient.fast_phone){
           return  this.$message.error('请输入陪护人电话');
        }

        
        let d={
            name:this.patient.name,
            id:this.patient.id,
            id_card:this.patient.id_card,
            gender:this.patient.gender,
            age:this.patient.age,
            phone:this.patient.phone,
            
            birthday:this.patient.birthday,
            address:this.patient.address,
            fast_name:this.patient.fast_name,

            fast_phone:this.patient.fast_phone,
        }

              
            this['_API'].postMemberSave(d).then(res=>{
                    if(res.code==200){
                          this.$message({
                                message: res.message,
                                type: 'success'
                            });
                            this.thatF.thatF.handleClick()
                            this.thatF.patient.show=false;
                            // this.$emit('openUserInfo',this.params,res.data);
                    }
            })
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleSelect() {},

    
    
  },
  components: {
    ViewTitle,
    //  FormInfo
  },
};
</script>
<style lang='scss' scoped>
.addUserInfo {
padding: 0 4%;
  .box1 {
    display: flex;
    flex-wrap: wrap;
    padding: 20px 0;
    > div {
      position: relative;
      width: 20%;
      display: flex;
      align-items: center;
      // justify-content: center;
      margin-bottom: 20px;

      > span {
        display: inline-block;
        max-width: 80px;
        min-width: 80px;
        color: black;
        font-weight: bold;
      }
      /deep/ .el-input {
        width: 150px;
      }
    }
  }
  .box3 {
    margin: 20px 0;
  }

  .dukaBut {
    margin: 0px 0 20px;
  }
}

.buts{
    display: flex;
    align-items: center;
    justify-content: center;
    button{
        

    width: 200px;
    position: absolute;
    bottom: 28px;
    right: 45px;
    }
}


</style>